package com.bit.dreamer;

import java.util.ArrayList;

import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class DreamAdapter extends BaseAdapter {
	private Context context;
	private LayoutInflater inflater;
	private ArrayList<ListContent> arData;
	private int layout;

	public DreamAdapter(Context context, int layout,
			ArrayList<ListContent> arData) {
		this.context = context;
		this.inflater = (LayoutInflater)context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
		this.arData = arData;
		this.layout=layout;
	}
	
	@Override
	public int getCount() {
		return arData.size();
	}

	@Override
	public Object getItem(int position) {
		return arData.get(position).toString();
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null){
			convertView = this.inflater.inflate(layout, parent, false);
		}
		ImageView image = (ImageView)convertView.findViewById(R.id.img_dream);
//		image.setImageURI(Uri.parse(arData.get(position).uri));
//		image.setImageBitmap(arData.get(position).bitmap);
//		image.setImageURI(Uri.parse(arData.get(position).uri));
		image.setImageBitmap(arData.get(position).bitmap);
		
		
		
		TextView title = (TextView)convertView.findViewById(R.id.txt_title);
		title.setText(arData.get(position).title);
		
		TextView memo = (TextView)convertView.findViewById(R.id.txt_memo);
		memo.setText(arData.get(position).memo);
		return convertView;
	}
	
	

}
